﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Card.Make.Pro.Application.Helper;
using Card.Make.Pro.Form;
using Card.Make.Pro.Properties;
using DevExpress.LookAndFeel;

namespace Card.Make.Pro
{
    public partial class FrmMain : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public FrmMain()
        {
            InitializeComponent();

            // 初始化皮肤
            UserLookAndFeel.Default.SetSkinStyle( "Office 2010 Blue");
        }

        private readonly AssemblyHelper _assemblyHelper = new AssemblyHelper();


        /// <summary>
        /// 参会人查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButAttendeeQuery_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var frm = new FrmAttendeeQuery();
            OpenMdiFromLink(e.Item.Caption, frm);
        }



        /// <summary>
        /// 打开窗体连接
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="form">窗体</param>
        private void OpenMdiFromLink(string title, System.Windows.Forms.Form form)
        {
            foreach (System.Windows.Forms.Form frm in this.MdiChildren)
            {
                if (frm.GetType() == form.GetType())
                {
                    frm.BringToFront();
                    frm.Activate();
                    return;
                }
            }

            form.Text = title;
            form.MdiParent = this;
            form.Show();
            xtrBarMenuTabbedMdiManager.SelectedPage = xtrBarMenuTabbedMdiManager.Pages[form];
        }


        /// <summary>
        /// 加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmMain_Load(object sender, EventArgs e)
        {
            var frm = new FrmHome();
            OpenMdiFromLink("首页", frm);
        }

        private void barButApplicationQuery_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FrmApplicationQuery frm = new FrmApplicationQuery();
            OpenMdiFromLink("受理单信息", frm);
        }


        private void ButSystemLog_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var frm = new Frm_Dialog();
            OpenMdiFromLink("系统日志", frm);
        }


        /// <summary>
        /// 快速统计
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButStats_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var frm = new FrmStats();
            OpenMdiFromLink("快速统计", frm);
        }

        private void barButOutput_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var frm = new Frm_QuickOut();
            OpenMdiFromLink("快捷输出", frm);
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var frm = new Frm_Device();
            OpenMdiFromLink("设备信息", frm);
        }
    }
   
}
